package com.dominator.serviceImpl;

import com.dominFramework.core.typewrap.Dto;
import com.dominFramework.core.typewrap.Dtos;
import com.dominFramework.core.utils.SystemUtils;
import com.dominator.enums.ReqEnums;
import com.dominator.mybatis.dao.T_adminDao;
import com.dominator.mybatis.dao.T_adminPO;
import com.dominator.service.ApiAdminService;
import com.dominator.utils.api.ApiMessage;
import com.dominator.utils.api.ApiMessageUtil;
import com.dominator.utils.encode.Des3Utils;
import com.dominator.utils.exception.ApiException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ApiAdminServiceImpl implements ApiAdminService {

    @Autowired
    T_adminDao t_adminDao;


    @Override
    public ApiMessage login(Dto dto) throws ApiException {
        Dto qDto= Dtos.newDto();
        qDto.put("user_name",dto.getString("userName"));
        qDto.put("password", Des3Utils.encode(dto.getString("password")));
        T_adminPO t_adminPO=t_adminDao.selectOne(dto);
        if (SystemUtils.isEmpty(t_adminPO)){
           throw new ApiException(ReqEnums.REQ_USER_NOT_EXSIT);
        }

        return ApiMessageUtil.success();
    }
}
